<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
    <style>
      .item {
        border: 1px solid orange;
        margin: 10px 0;
        padding: 10px;
      }
    </style>
  </head>
  <body>
    <div id="root"></div>
    <script src="./lib/react.js"></script>
    <script src="./lib/react_dom.js"></script>
    <script src="./lib/babel.js"></script>

    <script type="text/babel">
      class App extends React.Component {
        constructor() {
          super()
          this.state = {
            message: 'hello world',
            students: [
              { id: 111, name: 'why', score: 99 },
              { id: 122, name: 'kobe', score: 98 },
              { id: 133, name: 'jame', score: 199 },
              { id: 144, name: 'currey', score: 198 },
              { id: 144, name: 'currey1', score: 200 },
            ],
          }
        }

        render() {
          const { message, students } = this.state
          return (
            <div>
              <h2>{message}</h2>
              <ul>
                {/*
                  {students.map((student) => (
                    <div className="item">
                      <h2>学号： {student.id}</h2>
                      <h2>姓名： {student.name}</h2>
                      <h2>分数： {student.score}</h2>
                    </div>
                  ))}
                */}

                {students
                  .filter((student) => student.score > 100)
                  .slice(0, 2)
                  .map((item) => (
                    <div className="item" key={item.id}>
                      <h2>学号： {item.id}</h2>
                      <h2>姓名： {item.name}</h2>
                      <h2>分数： {item.score}</h2>
                    </div>
                  ))}
              </ul>
            </div>
          )
        }
      }

      const root = ReactDOM.createRoot(document.querySelector('#root'))
      root.render(<App />)
    </script>
  </body>
</html>
